package de.unistuttgart.iaas.interaction.mail.util;

import java.io.*;
import java.util.Properties;
import org.apache.log4j.*;

/**
 * This class defines a object, with which all information in the file configuration.conf can be taken.
 * @author Lina Sun
 *
 */
public class ConfigFileHandler 
{
	protected String strFile = "";
	
	FileInputStream propInFile = null;
	
	public Properties propConfig = new Properties();
	
	private static Logger logger = Logger.getLogger(ConfigFileHandler.class);	
	
	static String MailAddress = "MailAddress";
	static String RecieveHost = "RecieveHost";
	static String RecievePort = "RecievePort";
	static String SendHost = "SendHost";
	static String SendPort = "SendPort";
	static String Username = "Username";
	static String Password = "Password";
	static String AttPath = "AttPath";
	static String db_username ="db_username";
	static String db_password ="db_password";
	static String db_url = "db_url";
	static String db_table_mailbox = "db_table_mailbox";
	static String db_table_sentmails = "db_table_sentmails";
	static String db_table_mailattachments = "db_table_mailattachments";
	static String db_table_mailregister = "db_table_mailregister";
	static String xsdHeader = "xsdHeader";
	static String xsdFoot = "xsdFoot";
	static String xmlHeader = "xmlHeader";
	static String xmlFoot = "xmlFoot";
	static String tag = "tag";
		
	public ConfigFileHandler(String strFile)
	{
		try
		{
			propInFile = new FileInputStream(strFile);
			propConfig.load(propInFile);
		}
		catch(IOException ex)
		{
			logger.error("Configurationsfile can't be opened.");
		}
	}
	
	public String getTag()
	{
		return propConfig.getProperty(tag);
	}
	public String getXsdHeader()
	{
		return propConfig.getProperty(xsdHeader);
	}
	public String getXsdFoot()
	{
		return propConfig.getProperty(xsdFoot);
	}
	public String getXmlHeader()
	{
		return propConfig.getProperty(xmlHeader);
	}
	public String getXmlFoot()
	{
		return propConfig.getProperty(xmlFoot);
	}
	
	public String getMailAddress()
	{
		return propConfig.getProperty(MailAddress);
	}

	public String getRecieveHost()
	{
		return propConfig.getProperty(RecieveHost);
	}
	
	public int getRecievePort()
	{
		return Integer.parseInt(propConfig.getProperty(RecievePort));
	}
	
	public String getSendHost()
	{
		return propConfig.getProperty(SendHost);
	}
	
	public int getSendPort()
	{
		return Integer.parseInt(propConfig.getProperty(SendPort));
	}
	
	public String getUsername()
	{
		return propConfig.getProperty(Username);
	}
	
	public String getPassword()
	{
		return propConfig.getProperty(Password);
	}
	
	public String getAttPath()
	{
		return propConfig.getProperty(AttPath);
	}
	
	public String getDB_username()
	{
		return propConfig.getProperty(db_username);
	}
	
	public String getDB_password()
	{
		return propConfig.getProperty(db_password);
	}
	
	public String getDB_url()
	{
		return propConfig.getProperty(db_url);
	}
	
	public String getTable_mailbox()
	{
		return propConfig.getProperty(db_table_mailbox);
	}
	
	public String getTable_sentmails()
	{
		return propConfig.getProperty(db_table_sentmails);
	}
	public String getTable_mailattachments()
	{
		return propConfig.getProperty(db_table_mailattachments);
	}
	public String getTable_mailregister()
	{
		return propConfig.getProperty(db_table_mailregister);
	}	
	
}
